<?php
Route::prefix("admin")
    ->namespace("Admin")
    ->name("admin.")
    ->group(function (){
    Route::get("/login","LoginController@index")->name("login"); //后台登录页
    Route::post("/login","LoginController@check")->name("login"); //后台登录校验
});

//后台路由
Route::prefix("admin")
    ->namespace("Admin")
    ->middleware("admin_check")
    ->name("admin.")
    ->group(function (){
    //后台首页
    Route::get("/index","IndexController@index")->name("index");

    //菜单
    Route::group(['prefix'=>"menu"],function(){
        Route::get("/index","MenuController@index")->name("menu.index");
        Route::get("/create","MenuController@create")->name("menu.create");
        Route::post("/store","MenuController@store")->name("menu.store");
    });

    //配置
    Route::prefix("config")->group(function(){
        Route::get("/site","ConfigController@site")->name("config.site");
        Route::post("/store","ConfigController@store")->name("config.store");
        Route::get("/info","ConfigController@info")->name("config.info");
        Route::get("/baidu","ConfigController@baidu")->name("config.baidu");
    });

    //新闻
    Route::resource("/news","NewsController")->except('destroy');
    Route::get("/news/{news}/del","NewsController@destroy")->name("news.delete");

    //产品分类
    Route::group(['prefix'=>"category"],function(){
        Route::get("/","CategoryController@index")->name("category.index");
        Route::get("create","CategoryController@create")->name("category.create");
        Route::post("store","CategoryController@store")->name("category.store");
        Route::get("edit/{cate}","CategoryController@edit")->name("category.edit");
        Route::post("update/{cate}","CategoryController@update")->name("category.update");
        Route::get("delete/{cate}","CategoryController@destory")->name("category.delete");
    });

    //产品
    Route::resource("/product","ProductController")->except('destroy');
    Route::get("/product/{product}/del","ProductController@destroy")->name("product.delete");
});

//图片上传
Route::prefix("admin")->namespace("\App\Http\Services")->name("admin.")->group(function (){
    Route::post("upload/store",'Upload@store')->name("upload.store");
});
